package com.george.es.book.controller.view.user;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.HashMap;

/**
 * <p>
 *  用户模块——页面视图——前端控制器
 * </p>
 *
 * @author GeorgeChan 2019/9/5 9:26
 * @version 1.0
 * @since jdk1.8
 */
@Controller
public class UserViewController {
    /**
     * 用户首页
     * @return 首页地址
     */
    @GetMapping("/")
    public String userIndex() {
        return "layui/index";
    }

    /**
     * 用户首页
     * @return 首页地址
     */
    @GetMapping("/user")
    public String userIndexHome() {
        return "layui/index";
    }

    @GetMapping("/user/edit/{id}")
    public String editUser(@PathVariable(value = "id", required = false) int id, Model model) {
        model.addAttribute("data", new HashMap<>());
        return "layui/user-edit";
    }

    @GetMapping("/user/add")
    public String addUser() {
        return "layui/user-add";
    }
}
